package algorithms;

import network.Vertex;
import network.Edge;

import java.util.Set;
import java.util.HashSet;

public class GroupDegree implements DeploymentAlgorithm{

    // Number of non-group nodes that are connected to group members
    public int getCentrality(Set<Vertex> vertices) {
        Set<Vertex> neighbors = new HashSet<Vertex>();
        Vertex otherVertex;
        for (Vertex v: vertices){
            for (Edge e: v.getEdges()){                
                otherVertex = e.getOtherVertex(v);
                if (!vertices.contains(otherVertex))
                    neighbors.add(otherVertex);
            }
        }
        return neighbors.size();
    }
}
